package com.capsulode.excel.header;


import com.capsulode.excel.exception.ReadingProcessFailedException;

public class DefaultHeader<R, F> extends AbstractHeader<R, F>{

    private final CellConsumer<R, F> consumer;
    private final Class<F> fieldType;

    public DefaultHeader(String name,Class<F> fieldType, CellConsumer<R, F> consumer) {
        super(name);
        this.fieldType=fieldType;
        this.consumer = consumer;
    }

    @Override
    protected Class<F> type() {
        return fieldType;
    }

    @Override
    public void read(F f, R row) throws ReadingProcessFailedException {
        if (f != null) {
            consumer.read(f, row);
        }
    }
}
